package kr.co.casually.adapter;

import java.util.ArrayList;

import kr.co.casually.ImageLoader;
import kr.co.casually.MainActivity;
import kr.co.casually.R;
import kr.co.casually.types.ConcertData;
import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class SubjCodeArtListAdapter extends BaseAdapter {
    
    private Activity mActivity;
    static LayoutInflater inflater=null;
   
    ArrayList<ConcertData> mArrayList;
    
    /**
     *  ���ڷ� ��Ƽ��Ƽ, �̹��� url, title�� �޾� ����Ʈ�� ����
     *
     * */
    public SubjCodeArtListAdapter(Activity mActivity, ArrayList<ConcertData> arrayList) {
    	this.mActivity = mActivity;
    	this.mArrayList = arrayList;
        inflater = (LayoutInflater)mActivity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    }

    public int getCount() {
        return mArrayList.size();
    }

    public Object getItem(int position) {
        return position;
    }

    public long getItemId(int position) {
        return position;
    }
    
    public View getView(int position, View convertView, ViewGroup parent) {
        View vi=convertView;
        if(convertView==null)
            vi = inflater.inflate(R.layout.art_subj_list_item, null);

        TextView tvTitle=(TextView)vi.findViewById(R.id.title);;
        TextView tvDate=(TextView)vi.findViewById(R.id.date);;
        ImageView image=(ImageView)vi.findViewById(R.id.image);
        tvTitle.setText(mArrayList.get(position).getTitle());
        tvDate.setText(mArrayList.get(position).getStartDate() + " ~ " + mArrayList.get(position).getEndDate());
        
        MainActivity.imageLoader.DisplayImage(mArrayList.get(position).getImagepath(), mActivity, image);
        return vi;
    }
}